package objectOutputStream;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;

public class Demo3 {
    //将序列化的多个对象进行反序列化
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //1.创建反序列化对象
        ObjectInputStream ois = new ObjectInputStream( new FileInputStream("IODemo\\user.txt"));
        //2.读取数据
        ArrayList<User> list = (ArrayList<User>) ois.readObject();
        //3.打印输出
        for (User user : list) {
            System.out.println(user);
        }
        //4.释放资源
        ois.close();
    }
}
